﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class cp_member_favourite : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int iDaLogin = (Int32)Session["IsLogin"];
        if (iDaLogin == 0)
        {
            Response.Redirect("/Common/Login.aspx");
            return;
        }
        if (!Page.IsPostBack)
        {
            DataBindingMemberFavouriteInfor();
        }
    }

    protected void DataBindingMemberFavouriteInfor()
    {
        Code.MemberController controller = new Code.MemberController();
        grid1.DataSource = controller.GetMemberFavouriteInfor((Int32)Session["UserID"]);
        grid1.DataBind();
    }

    protected void Grid1_DeleteCommand(object sender, Obout.Grid.GridRecordEventArgs e)
    {
        object oProID = e.Record["idSanPham"];
        object oUserID = Session["UserID"];

        int pID;
        int mID;
        if (Int32.TryParse(oProID.ToString(), out pID)
            && Int32.TryParse(oUserID.ToString(), out mID))
        {
            Code.MemberController controller = new Code.MemberController();
            controller.removeFavPro(mID, pID);
        }
    }

    protected void Grid1_Rebind(object sender, EventArgs e)
    {
        if (Session["UserID"] != null)
            DataBindingMemberFavouriteInfor();
    }
}